package homework;

import java.util.Scanner;

public class Test {
    public static void main(String[] args) throws NumberFormatException{
        Scanner scanner=new Scanner(System.in);

        Student student=new Student();
        System.out.println("请输入姓名:");
        student.setName(scanner.nextLine());
        while (true){
            try {
                System.out.println("请输入年龄:");
                int age = Integer.parseInt(scanner.nextLine());
                student.setAge(age);

                System.out.println("请输入语文成绩");
                double chinese=Double.parseDouble(scanner.nextLine());
                student.setChineseScore(chinese);

                System.out.println("请输入数学成绩");
                double math=Double.parseDouble(scanner.nextLine());
                student.setMathScore(math);

                System.out.println("请输入英语成绩");
                double english=Double.parseDouble(scanner.nextLine());
                student.setEnglishScore(english);
                break;

            }catch (NumberFormatException e) {
                System.out.println("输入格式有误,请输入数字");
            }catch (setScoreException s){
                String message = s.getMessage();
                System.out.println(message);
            }
        }
        String s = student.toString();
        System.out.println(s);


    }
}
